Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic CUDA support #68

Merged
merged 17 commits into from
Oct 6, 2023
Merged

Basic CUDA support #68

merged 17 commits into from
Oct 6, 2023

Conversation

WardBrian
Copy link
Collaborator

Based off of #64.

Locally, the added type1 cuda tests are passing.
CI will probably take a couple iterations before it is all working.

There's not really much to this: I extended the get_nufft_func helper and switched to manually handling the necessary fftshifts, since the cuda functions don't (currently?) accept modeord

@WardBrian WardBrian requested a review from eickenberg October 6, 2023 15:39
@WardBrian WardBrian linked an issue Oct 6, 2023 that may be closed by this pull request
2 tasks
Base automatically changed from mike-consolidate-dimensionalities-type-1 to main October 6, 2023 16:50
Copy link
Collaborator

@eickenberg eickenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect, looks great to me!

pytorch_finufft/functional.py Show resolved Hide resolved
pytorch_finufft/functional.py Show resolved Hide resolved
pytorch_finufft/functional.py Show resolved Hide resolved

# CPU idiosyncracy that needs to be done differently
coord_ramps = torch.from_numpy(np.mgrid[slices])
coord_ramps = torch.from_numpy(np.mgrid[slices]).to(points.device)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will work, but allocates an array on cpu, then sends it to gpu. we may want to borrow from the prior code that uses torch.meshgrid(x_vals, y_vals, z_vals) after allocating x_vals=torch.arange(start, end, device=device) etc. that way it gets created on gpu.

This is second-order optimization probably, since there will likely be other bottlenecks to fix beforehand, so keep as is for now


grads_points = None
grad_values = None

ndim = points.shape[0]

nufft_func = get_nufft_func(ndim, 2)
nufft_func = get_nufft_func(ndim, 2, points.device.type)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sending points.device object doesn't work?

BTW do we know anything about how well cufinufft interacts with multple devices?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing cufinufft does not like multiple devices, but I haven't tried.

We definitely need more checks that the arrays are both on the same device (at least cpu/cuda, if not also checking they're on the same index of cuda)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and we could use points.device, but the only thing we care about for now is if it is cuda/cpu, so sending the type seemed simplest

pytorch_finufft/functional.py Show resolved Hide resolved
@WardBrian WardBrian merged commit 35fd706 into main Oct 6, 2023
0 of 4 checks passed
@WardBrian WardBrian deleted the feat/cuda-start branch October 6, 2023 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH cuda support
2 participants